package com.banesco.precargadepositos.interfaz.vistas;

import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Spinner;

import com.banesco.precargadepositosandroid.R;

/**
 * Vista que  permite realizar el manejo de los componentes de la ventana de datos del prepago de TDC
 * @author Juan Carlos Coello
 * Trascend NC - 09/2013
 */
public class DatosPrePagoTDC extends Base implements OnItemSelectedListener {
	        
	        @Override
			public void onCreate(Bundle savedInstanceState) {
	            super.onCreate(savedInstanceState);
	            
	            super.setContentView(R.layout.activity_datosprepagotdc, getString(R.string.titulo_datosprepagotdc));
	            
	            Spinner sTipoDocumentoDep = (Spinner) findViewById(R.id.sTipoDocumentoDep);
	            Spinner sTipoTarjeta = (Spinner) findViewById(R.id.sTipoTarjeta);
	            Spinner sTipoDocumentoBen = (Spinner) findViewById(R.id.sTipoDocumentoBen);
	            Spinner sTipoPreCarga = (Spinner) findViewById(R.id.sTipoPreCarga);
	            
		         // Create an ArrayAdapter using the string array and a default spinner layout
		         ArrayAdapter<CharSequence> adapterTipoDocumentoDep = ArrayAdapter.createFromResource(this,
		                 R.array.tiposDocumentos, android.R.layout.simple_spinner_item);
		         ArrayAdapter<CharSequence> adapterTipoTarjeta = ArrayAdapter.createFromResource(this,
		                 R.array.tiposTarjeta, android.R.layout.simple_spinner_item);
		         ArrayAdapter<CharSequence> adapterTipoDocumentoBen = ArrayAdapter.createFromResource(this,
		                 R.array.tiposDocumentos, android.R.layout.simple_spinner_item);
		         ArrayAdapter<CharSequence> adapterTipoPreCarga = ArrayAdapter.createFromResource(this,
		                 R.array.tipoPreCarga, android.R.layout.simple_spinner_item);
		         
		         // Specify the layout to use when the list of choices appears
		         adapterTipoDocumentoDep.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		         adapterTipoTarjeta.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		         adapterTipoDocumentoBen.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		         adapterTipoPreCarga.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		         
		         // Apply the adapter to the spinner
		         sTipoDocumentoDep.setAdapter(adapterTipoDocumentoDep);
		         sTipoTarjeta.setAdapter(adapterTipoTarjeta);
		         sTipoDocumentoBen.setAdapter(adapterTipoDocumentoBen);
		         sTipoPreCarga.setAdapter(adapterTipoPreCarga);
	        }

			@Override
			public void onItemSelected(AdapterView<?> arg0, View arg1,
					int arg2, long arg3) {
				// TODO Auto-generated method stub
				Spinner sTipoDocumentoDep = (Spinner) findViewById(R.id.sTipoDocumentoDep);
				sTipoDocumentoDep.setOnItemSelectedListener(this);
				Spinner sTipoDeposito = (Spinner) findViewById(R.id.sTipoTarjeta);
				sTipoDeposito.setOnItemSelectedListener(this);
				Spinner sTipoDocumentoBen = (Spinner) findViewById(R.id.sTipoDocumentoBen);
				sTipoDocumentoBen.setOnItemSelectedListener(this);
				Spinner sTipoPreCarga = (Spinner) findViewById(R.id.sTipoPreCarga);
				sTipoPreCarga.setOnItemSelectedListener(this);
				
			}

			@Override
			public void onNothingSelected(AdapterView<?> arg0) {
				// TODO Auto-generated method stub
				
			}
	           
	   }

